package com.taotao.chain.impl;

import com.taotao.chain.GatewayHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author: wangjin
 * @CreateTime: 2022-06-25  23:24
 */
@Slf4j
@Component
public class ConversationLimitHandler extends GatewayHandler {
    @Override
    public void doServices()throws Exception {
      log.info("<<第三关 判断用户是否验证token信息>");
        HttpServletRequest request = ((ServletRequestAttributes)
                RequestContextHolder.getRequestAttributes()).getRequest();
        String name = request.getParameter("name");
        if (StringUtils.isEmpty(name)) {
            throw new Exception("name is null");
        }
        if ("aaaa".equals(name)) {
            throw new Exception("权限不足");
        }
    }





}
